﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using AuctionModel;
using DataBaseController;

namespace AuctionLogicController
{
    public static class UserController
    {
        public static void CreateUser(User user)
        {
            if (user.Password.Length < 6)
            {
                throw new FaultException("The password must be at least 6 characters");
            }
            else if (DbCtr.UserExist(user))
            {
                throw new FaultException("The username already exists");
            }

            DbCtr.CreateUser(user);
        }

        public static User Login(string username, string password)
        {
            return DbCtr.LogIn(username , password);
        }
    }
}
